From a20eb37b989af2da0e28a2918a77e05d10dbc2e7 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 31 Oct 2005 21:26:33 +0000 Subject: [PATCH] Olaf and Robert improve help output. Add v3 format, min/max, provide defaults, data types, etc. --- gpsbabel/bcr.c | 2 +- gpsbabel/compegps.c | 6 +++--- gpsbabel/defs.h | 4 +++- gpsbabel/garmin.c | 2 +- gpsbabel/gdb.c | 4 ++-- gpsbabel/gpx.c | 7 ++----- gpsbabel/ignrando.c | 2 +- gpsbabel/mapsource.c | 7 ++----- gpsbabel/nmn4.c | 2 +- gpsbabel/overlay.c | 10 +++++----- gpsbabel/ozi.c | 7 ++----- gpsbabel/pathaway.c | 7 ++----- gpsbabel/position.c | 2 +- gpsbabel/psitrex.c | 2 +- gpsbabel/shape.c | 2 +- gpsbabel/smplrout.c | 2 +- gpsbabel/stackfilter.c | 2 +- gpsbabel/stmwpp.c | 3 ++- gpsbabel/tiger.c | 7 ++----- gpsbabel/vecs.c | 41 +++++++++++++++++++++++++++++++++++++++++ gpsbabel/xcsv.c | 2 +- 21 files changed, 76 insertions(+), 47 deletions(-) diff --git a/gpsbabel/bcr.c b/gpsbabel/bcr.c index 302cfca3a..702ea814c 100644 --- a/gpsbabel/bcr.c +++ b/gpsbabel/bcr.c @@ -58,7 +58,7 @@ static char *radius_opt; static arglist_t bcr_args[] = { - {"index", &rtenum_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT }, + {"index", &rtenum_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL }, {"name", &rtename_opt, "New name for the route", NULL, ARGTYPE_STRING }, {"radius", &radius_opt, "Radius of our big earth (default 6371000 meters)", NULL, ARGTYPE_FLOAT }, {0, 0, 0, 0, 0} diff --git a/gpsbabel/compegps.c b/gpsbabel/compegps.c index 40704f992..ba20227ad 100644 --- a/gpsbabel/compegps.c +++ b/gpsbabel/compegps.c @@ -91,11 +91,11 @@ arglist_t compegps_args[] = { {"deficon", &option_icon, "Default icon name", NULL, ARGTYPE_STRING}, {"index", &option_index, "Index of route/track to write (if more the one in source)", - NULL, ARGTYPE_INT}, + NULL, ARGTYPE_INT, "1", NULL}, {"radius", &option_radius, "Give points (waypoints/route points) a default radius (proximity)", - NULL, ARGTYPE_FLOAT}, + NULL, ARGTYPE_FLOAT, "0", NULL}, {"snlen", &option_snlen, "Length of generated shortnames (default 16)", - NULL, ARGTYPE_INT}, + "16", ARGTYPE_INT, "1", NULL}, {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 05b663966..97b47b132 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -470,7 +470,9 @@ typedef struct arglist { char **argval; char *helpstring; char *defaultvalue; - long argtype; + gbuint32 argtype; + char *minvalue; /* minimum value for numeric options */ + char *maxvalue; /* maximum value for numeric options */ } arglist_t; typedef enum { diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 184b37c32..8899af721 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -43,7 +43,7 @@ static char valid_waypt_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"; static arglist_t garmin_args[] = { { "snlen", &snlen, "Length of generated shortnames", NULL, - ARGTYPE_INT }, + ARGTYPE_INT, "1", NULL }, { "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", NULL, ARGTYPE_BOOL}, { "deficon", &deficon, "Default icon name", NULL, ARGTYPE_STRING }, diff --git a/gpsbabel/gdb.c b/gpsbabel/gdb.c index 4121f2b8a..5359a39f1 100644 --- a/gpsbabel/gdb.c +++ b/gpsbabel/gdb.c @@ -94,9 +94,9 @@ static char *gdb_opt_via = NULL; static arglist_t gdb_args[] = { {GDB_OPT_CATEGORY, &gdb_opt_category, - "Default category on output (1..16)", NULL, ARGTYPE_INT}, + "Default category on output (1..16)", NULL, ARGTYPE_INT, "1", "16"}, {GDB_OPT_VER, &gdb_opt_ver, - "Version of gdb file to generate (1,2)", "2", ARGTYPE_INT}, + "Version of gdb file to generate (1,2)", "2", ARGTYPE_INT, "1", "2"}, {GDB_OPT_VIA, &gdb_opt_via, "Drop route points, if they don't have an aquivalent waypoint (hidden points)", NULL, ARGTYPE_BOOL}, {0, 0, 0, 0, 0} diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index d4485969a..4e7c841f2 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -1435,10 +1435,7 @@ gpx_write(void) now = current_time(); - if (snlen) - short_length = atoi(snlen); - else - short_length = 32; + short_length = atoi(snlen); if (suppresswhite) { setshort_whitespace_ok(mkshort_handle, 0); @@ -1495,7 +1492,7 @@ gpx_exit(void) static arglist_t gpx_args[] = { { "snlen", &snlen, "Length of generated shortnames", - NULL, ARGTYPE_INT }, + "32", ARGTYPE_INT, "1", NULL }, { "suppresswhite", &suppresswhite, "Suppress whitespace in generated shortnames", NULL, ARGTYPE_BOOL }, diff --git a/gpsbabel/ignrando.c b/gpsbabel/ignrando.c index 152f3ba7e..4320be433 100644 --- a/gpsbabel/ignrando.c +++ b/gpsbabel/ignrando.c @@ -48,7 +48,7 @@ static char *index_opt = NULL; static arglist_t ignr_args[] = { - {"index", &index_opt, "Index of track to write (if more the one in source)", NULL, ARGTYPE_INT }, + {"index", &index_opt, "Index of track to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL }, {0, 0, 0, 0 } }; diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index 200efe710..a029285ca 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -74,7 +74,7 @@ char *mpsuseprox = NULL; static arglist_t mps_args[] = { - {"snlen", &snlen, "Length of generated shortnames", NULL, ARGTYPE_INT }, + {"snlen", &snlen, "Length of generated shortnames", "10", ARGTYPE_INT, "1", NULL }, { "snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", NULL, ARGTYPE_BOOL}, {"mpsverout", &mpsverout, @@ -1916,10 +1916,7 @@ mps_write(void) unsigned char copybuf[8192]; - if (snlen) - short_length = atoi(snlen); - else - short_length = 10; + short_length = atoi(snlen); if (mpsmergeout) { /* need to skip over the merging header and test merge version */ diff --git a/gpsbabel/nmn4.c b/gpsbabel/nmn4.c index c80f6df9c..08db1b4ac 100644 --- a/gpsbabel/nmn4.c +++ b/gpsbabel/nmn4.c @@ -45,7 +45,7 @@ static char *index_opt; static arglist_t nmn4_args[] = { - {"index", &index_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT }, + {"index", &index_opt, "Index of route to write (if more the one in source)", NULL, ARGTYPE_INT, "1", NULL }, {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/overlay.c b/gpsbabel/overlay.c index c462077b4..95d0e6f7d 100644 --- a/gpsbabel/overlay.c +++ b/gpsbabel/overlay.c @@ -78,9 +78,9 @@ static char *govl_file_s = NULL; static arglist_t ovl_args[] = { { "col", &govl_col_s, "color index [1-9] for routes", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "1", "9" }, { "size", &govl_size_s, "size index [101-] for routes", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "101", NULL }, { "mapname", &govl_mapname, "name of map", NULL, ARGTYPE_STRING }, { "zoomfc", &govl_zoomfc_s, "zoom factor of map in %", @@ -88,11 +88,11 @@ static arglist_t ovl_args[] = { { "dimmfc", &govl_dimmfc_s, "dimmer factor of map in %", NULL, ARGTYPE_INT }, { "txtcol", &govl_txtcol_s, "color index [1-9] for waypoint names", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "1", "9" }, { "txtsize", &govl_txtsize_s, "text size [101-] for waypoint names", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "101", NULL }, { "font", &govl_font_s, "font index [1-] for waypoint names", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "1", NULL }, { "txttrans", &govl_txttrans_s, "set text background to transparent", NULL, ARGTYPE_BOOL }, { "file", &govl_file_s, "use file of parameters (parameters on command line overwrites file parameters)", diff --git a/gpsbabel/ozi.c b/gpsbabel/ozi.c index b35cbb40c..ce48e8f6e 100644 --- a/gpsbabel/ozi.c +++ b/gpsbabel/ozi.c @@ -48,7 +48,7 @@ static char *snuniqueopt = NULL; static arglist_t ozi_args[] = { {"snlen", &snlenopt, "Max synthesized shortname length", - NULL, ARGTYPE_INT}, + "32", ARGTYPE_INT, "1", NULL}, {"snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", NULL, ARGTYPE_BOOL}, {"snupper", &snupperopt, "UPPERCASE synth. shortnames", @@ -286,10 +286,7 @@ wr_init(const char *fname) /* set mkshort options from the command line if applicable */ if (global_opts.synthesize_shortnames) { - if (snlenopt) - setshort_length(mkshort_handle, atoi(snlenopt)); - else - setshort_length(mkshort_handle, 32); + setshort_length(mkshort_handle, atoi(snlenopt)); if (snwhiteopt) setshort_whitespace_ok(mkshort_handle, atoi(snwhiteopt)); diff --git a/gpsbabel/pathaway.c b/gpsbabel/pathaway.c index 0f9f559cb..0f2846989 100644 --- a/gpsbabel/pathaway.c +++ b/gpsbabel/pathaway.c @@ -65,7 +65,7 @@ static arglist_t ppdb_args[] = { {"dbname", &dbname, "Database name", NULL, ARGTYPE_STRING}, {"deficon", &deficon, "Default icon name", NULL, ARGTYPE_STRING}, - {"snlen", &snlen_opt, "Length of generated shortnames", NULL, ARGTYPE_INT }, + {"snlen", &snlen_opt, "Length of generated shortnames", "10", ARGTYPE_INT, "1", NULL }, {0, 0, 0, 0, 0 } }; @@ -509,10 +509,7 @@ static void ppdb_wr_init(const char *fname) if (global_opts.synthesize_shortnames != 0) { - if (snlen_opt != NULL) - len = atoi(snlen_opt); - else - len = 10; + len = atoi(snlen_opt); setshort_length(mkshort_handle, len); setshort_mustupper(mkshort_handle, 1); setshort_badchars(mkshort_handle, ","); diff --git a/gpsbabel/position.c b/gpsbabel/position.c index 261708c7a..72a7ef299 100644 --- a/gpsbabel/position.c +++ b/gpsbabel/position.c @@ -67,7 +67,7 @@ arglist_t radius_args[] = { {"nosort", &nosort, "Inhibit sort by distance to center.", NULL, ARGTYPE_BOOL }, {"maxcount", &maxctarg,"Output no more than this number of points", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "1", NULL }, {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/psitrex.c b/gpsbabel/psitrex.c index 79bc631bf..bd0aa8b3c 100755 --- a/gpsbabel/psitrex.c +++ b/gpsbabel/psitrex.c @@ -57,7 +57,7 @@ char *snlen; static arglist_t psit_args[] = { /* {"snlen", &snlen, "Length of generated shortnames", - NULL, ARGTYPE_INT }, */ + NULL, ARGTYPE_INT, "1", NULL }, */ {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/shape.c b/gpsbabel/shape.c index e4deb52c2..607f62ed5 100644 --- a/gpsbabel/shape.c +++ b/gpsbabel/shape.c @@ -39,7 +39,7 @@ static char *opt_name = NULL; static arglist_t shp_args[] = { {"name", &opt_name, "Index of name field in .dbf", - NULL, ARGTYPE_INT }, + NULL, ARGTYPE_INT, "0", NULL }, { 0, 0, 0, 0} }; diff --git a/gpsbabel/smplrout.c b/gpsbabel/smplrout.c index 7688582dc..9659c80db 100644 --- a/gpsbabel/smplrout.c +++ b/gpsbabel/smplrout.c @@ -30,7 +30,7 @@ static char *countopt = NULL; static arglist_t routesimple_args[] = { {"count", &countopt, "Maximum number of points in route", - NULL, ARGTYPE_INT | ARGTYPE_REQUIRED}, + NULL, ARGTYPE_INT | ARGTYPE_REQUIRED, "1", NULL}, {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/stackfilter.c b/gpsbabel/stackfilter.c index 38bfd4854..6f973292f 100644 --- a/gpsbabel/stackfilter.c +++ b/gpsbabel/stackfilter.c @@ -53,7 +53,7 @@ arglist_t stackfilt_args[] = { {"replace", &opt_replace, "(pop) Replace list (default)", NULL, ARGTYPE_END_EXCL | ARGTYPE_BOOL}, {"depth", &opt_depth, "(swap) Item to use (default=1)", - NULL, ARGTYPE_INT}, + NULL, ARGTYPE_INT, "0", NULL}, {"nowarn", &nowarn, "Suppress cleanup warning", NULL, ARGTYPE_BOOL | ARGTYPE_HIDDEN}, {0, 0, 0, 0, 0} diff --git a/gpsbabel/stmwpp.c b/gpsbabel/stmwpp.c index 1abd3cf7d..638ee4adf 100644 --- a/gpsbabel/stmwpp.c +++ b/gpsbabel/stmwpp.c @@ -46,7 +46,8 @@ static char *index_opt = NULL; static arglist_t stmwpp_args[] = { - {"index", &index_opt, "Index of route/track to write (if more the one in source)", NULL, ARGTYPE_INT }, + {"index", &index_opt, "Index of route/track to write (if more the one in source)", + NULL, ARGTYPE_INT, "1", NULL }, {0, 0, 0, 0, 0} }; diff --git a/gpsbabel/tiger.c b/gpsbabel/tiger.c index 52c09157e..50b3a70bc 100644 --- a/gpsbabel/tiger.c +++ b/gpsbabel/tiger.c @@ -69,7 +69,7 @@ arglist_t tiger_args[] = { {"margin", &margin, "Margin for map. Degrees or percentage.", "15%", ARGTYPE_FLOAT}, {"snlen", &snlen, "Max shortname length when used with -s.", - NULL, ARGTYPE_INT}, + "10", ARGTYPE_INT, "1", NULL}, {"oldthresh", &oldthresh, "Days after which points are considered old.", "14", ARGTYPE_INT}, @@ -228,10 +228,7 @@ data_write(void) minlon = 9999.0; rec_cnt = 0; - if (snlen) - short_length = atoi(snlen); - else - short_length = 10; + short_length = atoi(snlen); mkshort_whandle = mkshort_new_handle(); if (suppresswhite) { diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 03b7c5ae7..7b5c6c08d 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -783,6 +783,43 @@ disp_v2(ff_vecs_t *v) putchar('\t'); } +const char * +name_option(long type) +{ + const char *at[] = { + "unknown", + "integer", + "float", + "string", + "boolean", + "file", + "outfile" + }; + + if ((type & ARGTYPE_TYPEMASK) <= 6) { + return at[type & ARGTYPE_TYPEMASK]; + } + return at[0]; +} + +static void +disp_v3(vecs_t *vec) +{ + arglist_t *ap; + + for (ap = vec->vec->args; ap && ap->argstring; ap++) { + if ( !(ap->argtype & ARGTYPE_HIDDEN)) + printf("option\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + vec->name, + ap->argstring, + ap->helpstring, + name_option(ap->argtype), + ap->defaultvalue? ap->defaultvalue : "", + ap->minvalue? ap->minvalue : "", + ap->maxvalue? ap->maxvalue : ""); + } +} + /* * Display the available formats in a format that's easy to machine * parse. Typically invoked by programs like graphical wrappers to @@ -799,6 +836,7 @@ disp_formats(int version) case 0: case 1: case 2: + case 3: svp = sort_and_unify_vecs(&vc); for (i=0;iname, vec->extension? vec->extension : "", vec->desc); + if (version >= 3) { + disp_v3(vec); + } } xfree (svp); break; diff --git a/gpsbabel/xcsv.c b/gpsbabel/xcsv.c index 5cff74c76..bbcffd75e 100644 --- a/gpsbabel/xcsv.c +++ b/gpsbabel/xcsv.c @@ -45,7 +45,7 @@ arglist_t xcsv_args[] = { {"style", &styleopt, "Full path to XCSV style file", NULL, ARGTYPE_FILE | ARGTYPE_REQUIRED }, {"snlen", &snlenopt, "Max synthesized shortname length", NULL, - ARGTYPE_INT}, + ARGTYPE_INT, "1", NULL}, {"snwhite", &snwhiteopt, "Allow whitespace synth. shortnames", NULL, ARGTYPE_BOOL}, {"snupper", &snupperopt, "UPPERCASE synth. shortnames", -- 2.30.2